#define _CRT_SECURE_NO_WARNINGS
#include <iostream>

using namespace std;
typedef long long LL;

LL gcd(LL a, LL b)
{
	return b == 0 ? a : gcd(b, a % b);
}
int main()
{
	LL n, m; cin >> n >> m;
	n++, m++;

	LL t = n * m;
	LL ret = t * (t - 1) * (t - 2) / 6;
	ret -= n * (m - 1) * (m - 2) * m / 6;
	ret -= m * n * (n - 1) * (n - 2) / 6;

	for (int i = 1; i < m; i++)
		for (int j = 1; j < n; j++)
			ret -= 2 * (m - i) * (n - j) * (gcd(i, j) - 1);
	cout << ret << endl;
	return 0;
}